<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.6/iconfont.css" rel="stylesheet"
	type="text/css" />
<link href="lib/webuploader/0.1.5/webuploader.css" rel="stylesheet"
	type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>新增U_circle_cate</title>
</head>
<body>
	<div class="pd-20">
		<form action="<%=path%>/backstage/u_circle_cate-add" method="post"
			class="form form-horizontal" id="form-u_circle_cate-add">
			<input type="hidden" id="id" name="id" value='${u_circle_cate.id}' />

			<div class="row cl" style="display: none;">
				<label class="form-label col-2">父类ID：</label>
				<div class="formControls col-2">
					<input type="text" class="input-text" value="-1" placeholder=""
						id="" name="parent_id" datatype="*" nullmsg="不能为空">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-2">类名：</label>
				<div class="formControls col-2">
					<input type="text" class="input-text"
						value="${u_circle_cate.cate_name}" placeholder="" id=""
						name="cate_name" datatype="*" nullmsg="不能为空">
				</div>
			</div>
			<div class="row cl" style="display: none;">
				<label class="form-label col-2">描述：</label>
				<div class="formControls col-2">
					<input type="text" class="input-text"
						value="${empty u_circle_cate.cate_desc?"内容":u_circle_cate.cate_desc}" placeholder="" id=""
						name="cate_desc" datatype="*" nullmsg="">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-2">排序：</label>
				<div class="formControls col-2">
					<input type="text" class="input-text" value="${u_circle_cate.sort}"
						placeholder="" id="" name="sort" datatype="*" nullmsg="不能为空">
				</div>
			</div>
			<div class="row cl" style="display: none;">
				<label class="form-label col-2">类型：</label>
				<div class="formControls col-2">
					<input type="text" class="input-text" value="1" placeholder=""
						id="" name="type" datatype="*" nullmsg="不能为空">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-2">类别icon：</label>
				<div class="formControls col-2">
					<div class="uploader-thum-container">
						<div id="fileList" class="uploader-list">
							<c:if test="${!empty u_circle_cate.iconurl}">
								<div class="file-item thumbnail upload-state-done">
									<img style="width: 100px; height: 100px;"
										src="${u_circle_cate.iconurl}" />
									<div class="info"></div>
								</div>
							</c:if>
						</div>
						<div id="filePicker">选择图片</div>
					</div>
					<input type="hidden" class="input-text"
						value="${u_circle_cate.iconurl}" placeholder="" id="iconurl"
						name="iconurl" datatype="*" nullmsg="不能为空">
				</div>
			</div>


			<div class="row cl">
				<div class="col-10 col-offset-2">
					<button onClick="u_circle_cate_save_submit();"
						class="btn btn-primary radius" type="submit">
						<i class="Hui-iconfont">&#xe632;</i> 保存并提交
					</button>
					<button onClick="layer_close();" class="btn btn-default radius"
						type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
				</div>
			</div>
		</form>
	</div>
	</div>
	<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="lib/layer/2.1/layer.js"></script>
	<script type="text/javascript" src="lib/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="lib/icheck/jquery.icheck.min.js"></script>
	<script type="text/javascript"
		src="lib/Validform/5.3.2/Validform.min.js"></script>
	<script type="text/javascript"
		src="lib/webuploader/0.1.5/webuploader.min.js"></script>
	<script type="text/javascript"
		src="lib/ueditor/1.4.3/ueditor.config.js"></script>
	<script type="text/javascript"
		src="lib/ueditor/1.4.3/ueditor.all.min.js"></script>
	<script type="text/javascript"
		src="lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
	<script type="text/javascript" src="js/H-ui.js"></script>
	<script type="text/javascript" src="js/H-ui.admin.js"></script>
	<script type="text/javascript" src="js/uthinkjs/circle.js?v=1.1"></script>
	<script type="text/javascript">
		/****************初始化上传空间*************/
		var $list_icon = $('#fileList'), ratio = window.devicePixelRatio || 1, thumbnailWidth = 100 * ratio, thumbnailHeight = 100 * ratio,uploader_icon;

		uploader_icon = WebUploader.create({
			auto : true,
			swf : '<%=path%>/static/plugins/webuploader/0.1.5/Uploader.swf',
			server : '<%=path%>/backstage/common/uploadPic',
			pick : '#filePicker',
			fileSizeLimit : 400 * 1024, //400K
			accept : {
				title : 'Images',
				extensions : 'gif,jpg,jpeg,bmp,png,mp4,MP4',
				mimeTypes : 'image/jpg,image/jpeg,image/png,'
			},
			formData : {
				foldername : 'advert'
			}
		});
		// 当有文件被添加进队列的时候
		uploader_icon.on('fileQueued', function(file) {
			$list_icon
					.append('<div id="' + file.id + '" class="file-item item">'
							+
							//'<div class="info">' + file.name + '</div>' +
							'<p class="state">等待上传...</p>' + '</div>');
		});
		/*上传中*/
		uploader_icon
				.on(
						'uploadProgress',
						function(file, percentage) {
							var $li = $('#' + file.id), $percent = $li
									.find('.progress .progress-bar');
							// 避免重复创建
							if (!$percent.length) {
								$percent = $(
										'<div class="progress progress-striped active">'
												+ '<div class="progress-bar" role="progressbar" style="width: 0%">'
												+ '</div>' + '</div>')
										.appendTo($li).find('.progress-bar');
							}
							$li.find('p.state').text('上传中');
							$percent.css('width', percentage * 100 + '%');
						});
		/*上传成功*/
		uploader_icon
				.on(
						'uploadSuccess',
						function(file, response) {
							var $li;
							if (response.error == "0000") {
								$("#iconurl").val(response.datas);
								$li = $('<div id="' + file.id + '" class="file-item">'
										+ '<img style="height:150px;" src="'+response.datas+'"></div>');
							} else {
								$li = $('<div id="' + file.id + '" class="file-item">'
										+ '上传失败 </div>');
							}
							$list_icon.html($li);

						});

		uploader_icon.on('uploadError', function(file) {
			var $li = $('#' + file.id), $error = $li.find('div.error');
			if (!$error.length) {
				$error = $('<div class="error"></div>').appendTo($li);
			}
			$error.text('上传失败');
		});

		uploader_icon.on('uploadComplete', function(file) {
			$('#' + file.id).find('.progress').remove();
		});
		//  验证大小
		uploader_icon.on("error", function(type) {
			if (type == "F_DUPLICATE") {
				parent.layer.alert("请不要重复选择文件！");
			}
		});

		function u_circle_cate_save_submit() {
			$("#form-u_circle_cate-add")
					.Validform(
							{
								tiptype : 2,
								ajaxPost : true,
								callback : function(form) {
									var index = parent.layer
											.getFrameIndex(window.name);
									if (index) {//关闭弹出层
										parent.$('.btn-refresh').click();
										parent.layer.close(index);
									} else {//单独的页面
										location.href = "<%=path%>/backstage/u_circle_cate-list";
									}
								}
							});
		}
	</script>
</body>
</html>

